#include "friends.h"

// Friend function for matrix class - see matrix.h
template <class Y>
std::ostream& operator<<(std::ostream& os, const Matrix<Y>& matrix) {
    for (int i=0; i<matrix.size; i++) {
        os << "\t";
        for (int j=0; j<matrix.size; j++) {
            int idx = j + (i*matrix.size);
            os << matrix.elements[idx];
            if ((idx +1) % (matrix.size) != 0) {
                os << " ";
            } else {
                os << "\n";
            }
        }
    }
    return os;
}
template std::ostream& operator<<(std::ostream& os, const Matrix<int>& matrix);

// Friend function for matrix class - see matrix.h
template <class Y>
void operator++(Matrix<Y>& matrix, int unused) {
    for (int i=0; i<(matrix.size*matrix.size); i++) {
        matrix.elements[i]++;
    }
}
template void operator++(Matrix<int>& matrix, int unused);

// Friend function for matrix class - see matrix.h
template <class Y>
void operator--(Matrix<Y>& matrix, int unused) {
    for (int i=0; i<(matrix.size*matrix.size); i++) {
        matrix.elements[i]--;
    }
}
template void operator--(Matrix<int>& matrix, int unused);